#ifndef FRIENDLISTMODEL_H
#define FRIENDLISTMODEL_H


#include "appchat/data/userprofile.h"
#include "conversationmodel.h"

#include <QObject>
#include <QAbstractListModel>
#include <QtQml/qqml.h>


class FriendListModel : public QAbstractListModel
{
    Q_OBJECT
public:  
    enum BuddyRoles {
        IdRole = Qt::UserRole + 1,
        FullNameRole,
        DisplayNameRole,
        FirstNameRole,
        LastNameRole,
        BirthdayRole,
        GenderRole,
        MessageStatusRole,
        PhoneRole,
        PhoneOneRole,
        PhoneTwoRole,
        PhoneThreeRole,
        EmailRole,
        ProfileUrlRole,
        AvatarUrlRole,
        AvatarUrlLocalRole,
        TimeStatusRole,
        TypeMsg,
        FirstChar,
        OnlineRole,
        TotalMember
    };

    FriendListModel(QObject *parent = 0);

    void addBuddyItem(UserProfile* uProfile);

    void insertBuddyItem(UserProfile* uProfile, const int pos);

    int rowCount(const QModelIndex & parent = QModelIndex()) const;

    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;

    void clear();

    QList<UserProfile*> listBuddyItems() const {
        return m_listBuddyItems;
    }

    ConversationModel* getConversationModel(qint64 modelId);
    void insertConversationModel(qint64 buddyId, ConversationModel *conversationModel);

public slots:

    void setListBuddy(const QList<UserProfile*>& _buddyItems);
    void insertUnitBuddy(const QList<UserProfile *> aUnitFriends);

protected:
    QHash<int, QByteArray> roleNames() const;
    QList<UserProfile*> m_listBuddyItems;


};

QML_DECLARE_TYPE(FriendListModel)

#endif // FRIENDLISTMODEL_H
